<!DOCTYPE html>
<%@page import="java.util.*"%>
<%@page import="com.sad.model.*"%>
<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<html>
<head>
<%@ include file="/pages/inc/header.jsp"%>
<title><%=systemTitle%></title>
</head>
<%
	Orderback orderback = (Orderback)request.getAttribute("orderback");
	if(orderback==null)
		orderback = new Orderback();
%>
<body class="report">
	<div id="doc">
		<%@ include file="/pages/common/pageheader.jsp"%>

		<div class="bd clearfix">
			<div id="leftColContainer">
				<div class="leftCol noprint">
					<jsp:include page="/pages/common/pagemenu.jsp" flush="true">
						<jsp:param name="itemid" value="item2" />
						<jsp:param name="pageid" value="wish" />
					</jsp:include>
				</div>
			</div>
			<div id="mainContainer">
				<div class="contentCol">
					<form id="searchForm" action="render?pageid=expressform" method="POST"></form>
					<form id="exportForm" action="render?pageid=expressform&action=export" method="POST"></form>
					<input type="hidden" id="action_stats" value="expressform">

					<div id="b_center">
						<div id="test-mode-guide">
						
							<div id="test-mode-guide-col1" class="test-mode-guide-col">
								<h2>配送单</h2>
								<br/>
								
								<p>用户编号：&nbsp;&nbsp;<%=orderback.getUserId()%></p>
								<% if(orderback.getUser()!=null){ %>
								<p>用户名称：&nbsp;&nbsp;<%=orderback.getUser().getUsername()%></p>
								<p>用户地址：&nbsp;&nbsp;<%=orderback.getUser().getAddress() %></p>
								<p>用户电话：&nbsp;&nbsp;<%=orderback.getUser().getMobile()%></p>
								<%} else{%>
								<p>用户名称：&nbsp;&nbsp;</p>
								<p>用户地址：&nbsp;&nbsp;</p>
								<p>用户电话：&nbsp;&nbsp;</p>
								<%} if(orderback.getToy()!=null) {%>
								<p>玩具主题：&nbsp;&nbsp;<%=orderback.getToy().getToyTheme() %></p>
								<%} else{%>
								<p>玩具主题：&nbsp;&nbsp;</p>
								<%} %>
								<p>玩具编号：&nbsp;&nbsp;<%=orderback.getToyCode() %></p>
							</div>
							<form id="expressForm" name="expressForm" action="render?pageid=expressform&action=create" method="post">
							<input type="hidden" name="orderid" id="orderid" value="<%=orderback.getOrderId()%>" />
							<input type="hidden" name="userid" id="userid" value="<%=orderback.getUserId()%>" />
							<div id="test-mode-guide-col2" class="test-mode-guide-col-right" style="border-left: 1px solid #e3e3e3;">
								<h2>回收单</h2>
								<br/>
								<p>用户编号：&nbsp;&nbsp;<%=orderback.getUserId()%></p>
								<% if(orderback.getUser()!=null){ %>
								<p>用户名称：&nbsp;&nbsp;<%=orderback.getUser().getUsername()%></p>
								<p>用户地址：&nbsp;&nbsp;<%=orderback.getUser().getAddress() %></p>
								<p>用户电话：&nbsp;&nbsp;<%=orderback.getUser().getMobile()%></p>
								<%} else{%>
								<p>用户名称：&nbsp;&nbsp;</p>
								<p>用户地址：&nbsp;&nbsp;</p>
								<p>用户电话：&nbsp;&nbsp;</p>
								<%} if(orderback.getToy()!=null) {%>
								<p>玩具主题：&nbsp;&nbsp;<%=orderback.getToy().getToyTheme() %></p>
								<%} else{%>
								<p>玩具主题：&nbsp;&nbsp;</p>
								<%} %>
								<p>玩具编号：&nbsp;&nbsp;<%=orderback.getToyCode() %></p>
								<p>关键配件：&nbsp;&nbsp;<img src="<%=orderback.getToy().getUrl()%>" width="88px;" hight="66px;" /></p>
								<p>其他配件：&nbsp;&nbsp;<%=orderback.getToy().getToysetsCount() %></p>
								<p>快递公司：&nbsp;&nbsp;<input type="text" id="company" name="company" value="" style="width:250px;"/></p>
								<p>快递单号：&nbsp;&nbsp;<input type="text" id="excode" name="excode" value="" style="width:250px;"/></p>
								<p>快&nbsp;递&nbsp;&nbsp;员：&nbsp;&nbsp;<input type="text" id="courier" name="courier" value="" style="width:250px;"/></p>
								<p>快递电话：&nbsp;&nbsp;<input type="text" id="exmobile" name="exmobile" value="" style="width:250px;"/></p>
								<p>
									<input type="button" name="btn" value="录入快递信息" style="cursor:pointer" onclick="createExpress();"/>
									&nbsp;&nbsp;
									<input type="button" name="btn" value="打印投递单" style="cursor:pointer" onclick="javascrīpt:window.print()"/>
									&nbsp;
									<a href="render?pageid=wish">返回</a>
								</p>
							</div>
							</form>
						</div>

					</div>

				</div>
			</div>
		</div>
	</div>
<div class="hiddenft"></div>
<%@ include file="/pages/inc/footer.jsp"%>
<script type="text/javascript">
	function createExpress(){
		if($.trim($("#company").val())==""){
			alert("快递公司不能为空!");
			return false;
		}
		if($.trim($("#excode").val())==""){
			alert("快递单号不能为空!");
			return false;
		}
		if($.trim($("#courier").val())==""){
			alert("快递员不能为空！");
			return false;
		}
		if($.trim($("#exmobile").val())==""){
			alert("快递电话不能为空！");
			return false;
		}
		
		var orderid = $.trim($("#orderid").val());
		var userid = $.trim($("#userid").val());
		var company = $.trim($("#company").val());
		var excode = $.trim($("#excode").val());
		var courier = $.trim($("#courier").val());
		var exmobile = $.trim($("#exmobile").val());
			
		//$("#expressForm").submit(); 
			
		$.ajax({	
			type: 'POST',
			url: "render?pageid=expressform&action=create",
			dataType: "json",
			data: {orderid:orderid,userid:userid,company:company,courier:courier,exmobile:exmobile},
			success: function(data){
				if(data && data.success){
					alert("录入快递信息成功!可选择打印投递单操作！");
				}else{
					alert("录入快递信息失败!");
				}
			},
			error:function(data){
				alert("录入快递信息失败!");
			}
		});
			
	}
</script>
</body>
</html>